
# 编写程序统计其中每个字符出现的次数，并以字典形式返回

# s = "banana"
# dictA={}
#
# for a in s:
#     if dictA.get(a)!=None:
#         dictA[a]+=1
#     else:
#         dictA[a] = 1
# print(dictA)
#
# nums = [11, 2, 3, 4, 5]
# nums.reverse()   # 5 4 3 2 11      11 5 4 3 2
#
# nums.sort(reverse=True)
# print(nums)
# 编写一个函数 merge_sorted_lists(lst1, lst2)，合并两个升序排列的列表，
# 并返回合并后的有序列表例如：
# merge_sorted_lists([1, 3, 5], [2, 4, 6]) 输出: [1, 2, 3, 4, 5, 6]
#

# def merge_sorted_lists(lst1, lst2):
#     list1=lst1.extend(lst2)   lst1+lst2
#     list1.sort()
#     return   list1

nums = [10, 3, 5, 7, 9, 2]
def return_tuple(list1):
    max_num=max(list1)
    min_num=min(list1)
    # tuple1=(max_num,min_num)
    return max_num,min_num
#
# tuple1=1,2,3,4
# tuple2=(1,2,6,4)
#
# print(return_tuple(nums))

# def shu(a,b):
#     return b,a,1,2,3,4
# print(shu(1, 9))
class Animal:
    def __init__(self,name,sound):
        self.name=name
        self.sound=sound

    def make_sound(self):
        return  f"the {self.name} says {self.sound}"

class Dog(Animal):

    def __init__(self, name, sound):
        super().__init__(name, sound)

    def make_sound(self):
        return f"the {self.name}狗 says {self.sound}"

# 5! = 5×4×3×2×1 = 120
def factorial(n):
    cj=1
    s=""  #定义一个空字符串
    for num in  range(n,0,-1):
       cj*=num
       s+=str(num)+"x"
    # print(s[:-1])   # 把最后一位截取掉
    print(f"{n}! = {s[:-1]} = {cj}")
factorial(6)




